package com.jmgd.cjlx.controller;

import com.jmgd.cjlx.service.JmgdService;
import com.jmgd.cjlx.service.SendSMSService;
import com.jmgd.cjlx.service.TXYService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/jmgd")
public class JmgdController {
    @Autowired
    JmgdService jmgdService;

    @Autowired
    SendSMSService sendSMSService;

    @Autowired
    TXYService txyService;


    //邑康保拉数
    @RequestMapping(value = "/ykbls", method = RequestMethod.GET)
    public String ykbls() throws Exception {
        jmgdService.ykbls();
        return "success";
    }


    /**
     *拉取已开发票
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/queryInvoiceYk", method = RequestMethod.GET)
    public String queryInvoiceYk(String beginDateTime,String endDateTime,String orderId) throws Exception {
        beginDateTime = beginDateTime==null? beginDateTime:(beginDateTime+ " 00:00:00");
        endDateTime = endDateTime==null?endDateTime:(endDateTime + " 23:59:59");
        jmgdService.queryInvoiceYk(beginDateTime,endDateTime,orderId);
        return "成功";
    }


    /**
     *拉取商品税收编码
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/queryTaxCodeByWare", method = RequestMethod.GET)
    public String queryTaxCodeByWare(String name, String time) throws Exception {
        time = time==null?time:(time+" 00:00:00");
        jmgdService.queryTaxCodeByWare(name,time);
        return "成功";
    }


    /*
    发送短信
     */
    @RequestMapping(value = "/sendSMS", method = RequestMethod.GET)
    public String sendSMS(String mobile, String balance,String busname) throws Exception {
        sendSMSService.sendSMS(mobile,balance,busname);
        return "success";
    }


    /**
     *余额不足发送短信
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sendNotBalanceSMS", method = RequestMethod.GET)
    public String sendNotBalanceSMS(String mobile, String currentbalance,String busname,String balance) throws Exception {
        sendSMSService.sendNotBalanceSMS(mobile,currentbalance,busname,balance);
        return "success";
    }


    /**
     *短信
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sendChoujiang", method = RequestMethod.GET)
    public String sendChoujiang(String lotteryid) throws Exception {
        sendSMSService.sendChoujiang(lotteryid);
        return "success";
    }



    /**
     * 腾讯云语音消息
     * @param tel
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sendVoiceHWY", method = RequestMethod.GET)
    public String sendVoiceHWY(String tel) throws Exception {
        txyService.sendVoice(tel);
        return "success";
    }



    /**
     * 腾讯云语音消息
     * @param tel
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sendVoiceTXY", method = RequestMethod.GET)
    public String sendVoiceTXY(String tel) throws Exception {
        txyService.sendVoice(tel);
        return "success";
    }

}
